export const form_rules = {
  appointmentItem: [
    { required: true, message: '请输入预约项统一称谓', trigger: 'blur' }
  ],
  personnelItem: [
    { required: true, message: '请输入人员类资源统一称谓', trigger: 'blur' }
  ],
  reservationScope: [
    { required: true, message: '请输入预约范围', trigger: 'blur' }
  ],
  remindTime: [
    { required: true, message: '请输入', trigger: 'blur' }
  ],
  cancelOrderTime: [
    { required: true, message: '请输入', trigger: 'blur' }
  ],
  description: [
    { required: true, message: '请输入', trigger: 'blur' }
  ]
}

export const LIMIT_STATE = {
  MM: 1,
  HH: 2,
  D: 3
}

export const limitOptions = [
  {
    label: '分钟',
    value: LIMIT_STATE.MM
  },
  {
    label: '小时',
    value: LIMIT_STATE.HH
  },
  {
    label: '天',
    value: LIMIT_STATE.D
  }
]

export const supplyFacility = [
  {
    label: '网络',
    checkList: [],
    groupList: ['无线WIFI']
  },
  {
    label: '出行',
    checkList: [],
    groupList: ['停车场', '有电梯']
  },
  {
    label: '美食',
    checkList: [],
    groupList: ['中餐厅', '西餐厅', '咖啡厅', '酒吧', '便利店']
  },
  {
    label: '住房',
    checkList: [],
    groupList: [
      '24小时热水',
      '淋浴',
      '吹风机',
      '液晶电视',
      '电话',
      '国际长途电话'
    ]
  },
  {
    label: '商务',
    checkList: [],
    groupList: ['宴会厅', '会议室']
  },
  {
    label: '其它设施',
    checkList: [],
    groupList: []
  }
]
export const supplyService = [
  {
    label: '出行',
    checkList: [],
    groupList: [
      '行李寄存',
      '叫车服务',
      '租车服务',
      '自行车租赁',
      '旅行票务',
      '接送服务'
    ]
  },
  {
    label: '美食',
    checkList: [],
    groupList: ['送餐服务']
  },
  {
    label: '住房',
    checkList: [],
    groupList: ['叫醒服务', '洗衣服务']
  },
  {
    label: '其它服务',
    checkList: [],
    groupList: []
  }
]
export const resolveDifferMinute = (bt, et) => {
  const diffHour = Number(et.split(':')[0]) - Number(bt.split(':')[0])
  const DiffMinute = Number(et.split(':')[1]) - Number(bt.split(':')[1])
  return diffHour * 2 + (DiffMinute < 0 ? -1 : DiffMinute > 0 ? +1 : 0)
}
export const resolveDoubleTime = (times, begin, end, value) => {
  const arr = times.map(v => v.time)
  const beginHour = Number(begin.split(':')[0])
  const beginMinute = Number(begin.split(':')[1])
  const endHour = Number(end.split(':')[0])
  const endMinute = Number(end.split(':')[1])
  let beginIndex = null
  let endIndex = null
  arr.map((v, index) => {
    const hh = Number(v.split(':')[0])
    const mm = Number(v.split(':')[1])
    if ((hh === beginHour && mm === beginMinute)) {
      beginIndex = index
    }
    if (hh === endHour && mm === endMinute) {
      endIndex = index
    }
  })

  return times.map((item, index) => {
    if (index <= endIndex && index >= beginIndex) {
      item.max = value
    }
    return item
  })
}
